package geektime.controller;

import geektime.WeatherService;
import io.smallrye.mutiny.Uni;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * @Author chenlin
 * @Date 2022/3/16 22:48
 * @Description //TODO
 */
@Path("/weather")
@ApplicationScoped
public class WeatherController {

    @Inject
    private WeatherService weatherService;

    @GET
    @Path("/")
    @Produces(MediaType.TEXT_PLAIN)
    public String getWeather() {
      return weatherService.getCityWeather();
    }

    @GET
    @Path("/{city}")
    @Produces(MediaType.TEXT_PLAIN)
    public String getWeather(@PathParam("city") String city) {
        return weatherService.getCityWeather2(city);
    }

    @GET
    @Path("/reactive/{city}")
    public Uni<String> getWeather2(@PathParam("city") String city) {
        return weatherService.getCityWeather(city);
    }



}
